<template>
    <div>
        <van-nav-bar title="欢迎搜索" left-text="返回" left-arrow @click-left="() => { $router.push('/home/sy') }" fixed />
        <div style="height: 45px;"></div>
        <van-search v-model="value" shape="round" placeholder="请输入搜索关键词" />
        <van-empty v-if="qsearch.length == 0"
            image="https://fastly.jsdelivr.net/npm/@vant/assets/custom-empty-image.png" image-size="80"
            description="描述文字" />

        <van-cell-group v-for="item in qsearch">
            <router-link :to="'/home/xq/'+item.goods_id">
                <van-cell :title="item.goods_name" />
            </router-link>
            
        </van-cell-group>

    </div>
</template>

<script setup>
import { ref, watch } from 'vue'
import { qsearchApi } from '@/api/api'
let value = ref('')
let qsearch = ref([])

watch(value, (item) => {
    console.log('搜索', item)
    qsearchApi(item).then(res => {
        console.log('搜索数据', res)
        qsearch.value = res.data.message
    })
})
</script>

<style lang="scss" scoped></style>